(function() {"use strict";var __module = CC_EDITOR ? module : {exports:{}};var __filename = 'preview-scripts/assets/script/CameraMove.js';var __require = CC_EDITOR ? function (request) {return cc.require(request, require);} : function (request) {return cc.require(request, __filename);};function __define (exports, require, module) {"use strict";
cc._RF.push(module, '3f12bJzQY9FArmYA9iJ6yly', 'CameraMove', __filename);
// script/CameraMove.js

"use strict";

/**
 * 相机跟随人物移动
 */
cc.Class({
    extends: cc.Component,

    properties: {
        player: cc.Node
    },

    onLoad: function onLoad() {
        this.loading();
    },

    /**
    * 加载游戏所需要的资源
     */
    loading: function loading() {
        var _loop = function _loop(key) {
            var data = cc.vv.res[key]; //{url,type}
            cc.loader.loadRes(data.url, data.type, function (err, res) {
                if (err) {
                    cc.log(err);
                } else {
                    cc.vv.res[key] = res;
                }
            });
        };

        for (var key in cc.vv.res) {
            _loop(key);
        }
    },
    start: function start() {
        this.map = this.node.parent.getChildByName("map");
        this.schedule(this.zoomRatio, 0.01);
        this.scene = cc.director.getScene().name;
    },
    zoomRatio: function zoomRatio() {
        this.node.getComponent(cc.Camera).zoomRatio += 0.01;
    },
    update: function update(dt) {
        this.node.x = cc.misc.lerp(this.node.x, this.player.x, 0.1);
        this.node.y = cc.misc.lerp(this.node.y, this.player.y, 0.1);
        if (this.node.x <= 0 - cc.vv.SCALEFACTOR * 0.3) {
            this.node.x = -cc.vv.SCALEFACTOR * 0.3;
        }
        if (this.scene === "stage1") {
            if (this.node.x >= this.map.width - 960 + cc.vv.SCALEFACTOR * 0.3) {
                this.node.x = this.map.width - 960 + cc.vv.SCALEFACTOR * 0.3;
            }
            if (this.node.y <= -340 - cc.vv.SCALEFACTOR * 0.2) {
                this.node.y = -340 - cc.vv.SCALEFACTOR * 0.2;
            }
            if (this.node.y >= this.map.height - 600 - 270 + cc.vv.SCALEFACTOR * 0.2) {
                this.node.y = this.map.height - 600 - 270 + cc.vv.SCALEFACTOR * 0.2;
            }
        }if (this.scene === "stage2") {
            if (this.node.x >= this.map.width - 960 + cc.vv.SCALEFACTOR * 0.3) {
                this.node.x = this.map.width - 960 + cc.vv.SCALEFACTOR * 0.3;
            }
            if (this.node.y <= -416 - cc.vv.SCALEFACTOR * 0.2) {
                this.node.y = -416 - cc.vv.SCALEFACTOR * 0.2;
            }
            if (this.node.y >= this.map.height + 1713 - 270 + cc.vv.SCALEFACTOR * 0.2) {
                this.node.y = this.map.height + 1713 - 270 + cc.vv.SCALEFACTOR * 0.2;
            }
        }
        if (this.node.getComponent(cc.Camera).zoomRatio >= 1.3) {
            this.unschedule(this.zoomRatio);
        }
    }
});

cc._RF.pop();
        }
        if (CC_EDITOR) {
            __define(__module.exports, __require, __module);
        }
        else {
            cc.registerModuleFunc(__filename, function () {
                __define(__module.exports, __require, __module);
            });
        }
        })();
        //# sourceMappingURL=CameraMove.js.map
        